home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
wxtrm310.zip
/
WXTERM.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-06-11
|
17KB
|
606 lines
PROGRAM wxterm;
{$S-,R-,D+,L+,V-,B+} {3.08}
{$M 10240,0,0} {3.09}
USES Dos,CRT; {3.05}
{
Scott Murphy
77 So. Adams St. #301
Denver, CO 80209
Compuserve 70156,263
Defaults, help screen and hot keys improved. Ran thru Pascal
Formatter, changed to a two file program. Changed to Ver: 3.01
12-05-87 L.B. Neal, Sunnyvale, CA.
}
{**************************************************************}
{ Jun 1990. Upgraded to Turbo Pascal 5.0/5.5. Ver:3.04 }
{ Aug 1991. Corrected several items. New version is 3.05. }
{ Dec 1991. New goodies and StonyBrook support! 3.07 }
{ Mar 1992. Fixes and new Goodies!! New version 3.09 }
{ Apr 1992. Fixes and improvements. 3.10 }
{ L.B. Neal, Sunnyvale,CA. }
{**************************************************************}
TYPE
bigstring = STRING[80]; {general purpose}
Str90 = String[90]; {3.07}
cset = SET OF 0..127;
parity_set = (none, even); {readability and expansion}
CONST
Version = '3.10 '; { 11-JUN-92 Another look}
BELL_FREQ = 440; {frequency for bell sound}
BELL_DELAY = 100; {duration of bell sound}
DEFAULT_BAUD = 9600; {Serial port speed at start-up}
RECV_BUF_SIZE = 4097; {this may be changed to whatever size you need}
Buffer_End = RECV_BUF_SIZE-1; { safety margin }
ComPort : Byte = 3; { I use COM3: }
WxExit : Boolean = False; {3.05}
Cdet: Boolean = False; {3.08}
InitStr: String[60] = 'AT&C1&D2X4S0=0M0V1Q0'; {3.09}
VAR
AsyncVector: Pointer;
xtnd: Boolean;
a: Byte;
c,i: Integer;
ch: Char;
regs: Registers; { 3.04 }
INVLIST: Integer;
Buffer_Head,Buffer_Tail,Buffer_Count: Integer;
recv_buffer: ARRAY[1..RECV_BUF_SIZE] OF Byte;
speed: Integer; {I don't know the top speed these
routines will handle}
dbits : 7..8; {only ones most people use}
stop_bits : 1..2; {does anyone use 2?}
parity : parity_set; {even and none are the common ones}
Cport: String[4]; {3.04}
Base: Word; {3.04}
Async_Irq: Word; {3.04}
OutPort: Word; {3.04}
CdetPort: Word; {3.07}
junk: Char; {3.04}
PassStrg: BigString; {3.04}
wcol,wrow: Byte; {3.08}
fcol,frow: Byte; {3.09}
{$F+} { MUST be a FAR Procedure 3.04 }
PROCEDURE async_isr; Interrupt; {$F-} {3.09}
BEGIN
Inline($FB); {STI} {3.06}
Recv_Buffer[Buffer_Head] := Port[Base];
IF (Buffer_Head = Buffer_End) THEN
Buffer_Head := 1
ELSE
INC(Buffer_Head);
INC(Buffer_Count);
Port[$20] := $20;
END;
PROCEDURE DoBorder(FstCol,FstRow,LstCol,LstRow : Integer; Save:Boolean);
VAR i,thisrow,width,height,column: Integer; horiz: String[90];
BEGIN
IF save THEN wcol := WhereX; wrow := WhereY; {3.08}
Window(FstCol,FstRow,LstCol,LstRow);
ClrScr;
thisrow := 2;
width := (LstCol-FstCol)-2;
height := (LstRow-FstRow)-1;
column := Width+2;
FOR i := 1 to width DO horiz[i] := #205;
horiz[0] := Char(width);
Gotoxy(1,1); Write(Chr(201));
Write(horiz);
Write(Chr(187));
FOR i := 1 TO height DO
BEGIN
Gotoxy(1,thisrow); Write(Chr(186));
Gotoxy(column,thisrow); Write(Chr(186));
INC(thisrow);
END;
Gotoxy(1,thisrow); Write(CHR(200));
Write(horiz);
Write(#188);
END;
FUNCTION Carrier:Boolean;
BEGIN
Carrier := (port[CdetPort] AND 128) <> 0;
END;
FUNCTION CTS:Boolean; {3.07}
BEGIN
Cts := (Port[CdetPort] AND $10) <> 0;
END;
FUNCTION Wcgetc: Byte; { 3.04 }
BEGIN
INLINE($FA); {suspend interrupts}
wcgetc := Recv_Buffer[buffer_Tail];
IF Buffer_Tail < Buffer_End THEN { 3.04 safer this way }
INC(Buffer_Tail)
ELSE
Buffer_Tail := 1;
DEC(Buffer_Count);
INLINE($FB); {resume interrupts}
Port[$20] := $20; {3.05}
END;
PROCEDURE send(c:Integer); {3.09}
BEGIN
(* WHILE NOT Cts DO {NOP}; *)
WHILE (Port[CdetPort] AND $10) = 0 DO {NOP}; {3.09}
WHILE (port[outport] AND 32) = 0 DO {NOP};
port[base] := LO(c); {3.09}
END;
PROCEDURE sendstr(s:Str90); {3.09 Complete rewrite}
VAR size,cnt: Byte; ochar: Char; {3.09}
BEGIN
size := ORD(s[0]);
cnt := 1;
REPEAT
ochar := s[cnt]; {3.09}
IF ochar = '~' THEN {3.09}
Delay(500)
ELSE
BEGIN
WHILE NOT Cts DO {NOP};
WHILE (port[outport] AND 32) = 0 DO {NOP};
port[base] := ORD(ochar);
Delay(5); {3.08}
END;
INC(cnt);
UNTIL cnt > size;
port[base] := 13; {3.09}
END;
PROCEDURE set_baud(r:integer);
VAR a:byte; rw:word;
BEGIN
IF (r >= 300) AND (r <= 9600) THEN
BEGIN
CASE r OF {3.07}
2400: rw := 48;
1200: rw := 96;
9600: rw := 12; { 3.07 really 9600 bps }
300: rw := 384;
END;
a := port[base+3] OR 128;
port[base+3] := a;
port[base] := lo(rw);
port[base+1] := hi(rw);
port[base+3] := a AND 127;
Delay(500); {3.07 handle slow modems}
END
ELSE
BEGIN
Writeln('Invalid Baud Rate = ', r); { 2.0i }
Halt(1);
END;
END;
procedure dump;
begin
Inline($FA); {CLI}
buffer_head := 1;
buffer_tail := 1;
buffer_count := 0;
Inline($FB); {STI}
Port[$20] := $20; {3.05}
end;
procedure remove_port;
var i,m : Word;
begin
inline($FA); {CLI}
i := port[$21];
m := 1 SHL Async_Irq;
port[$21] := i OR m;
port[base+2] := 0;
port[base+4] := port[base+4] AND 1;
inline($FB); {STI}
Port[$20] := $20; {3.05}
end;
procedure term_ready(s:Boolean);
var x:byte;
begin
x := port[base+4] and $FE;
if s then x := x+1;
port[base+4] := x;
Delay(300); {for slow modem 3.07}
end;
PROCEDURE iport1;
BEGIN
CASE comport OF
1 : begin
base := $3f8; Async_Irq := 4; cport := 'COM1:';
end;
2 : begin
base := $2f8; Async_Irq := 3; cport := 'COM2:';
end;
3 : begin
base := $3E8; Async_Irq := 4; cport := 'COM3:';
end;
4 : begin
base := $2E8; Async_Irq := 3; cport := 'COM4:';
end;
ELSE
WriteLn('Invalid Comport:',comport);
Halt(1);
END; {case}
outport := Base+5;
cdetport := Base+6; {3.07}
END;
{3.08 NOTE: This needs to be fixed to adjust parity,bits and stopbits!}
PROCEDURE iport;
VAR i,m:Integer;
BEGIN
buffer_Head := 1;
buffer_Tail := 1;
buffer_Count := 0;
port[base+3]:= $03;
WITH regs DO
BEGIN
ah := $25; al := async_irq+8;
ds := cseg;
dx := ofs(async_isr);
msdos(regs);
END;
inline($FA);
i := port[base+5];
i := port[base];
i := port[$21];
m := (1 shl Async_Irq) xor $00FF;
port[$21] := i AND m;
port[base+1] := $01;
i := port[base+4];
port[base+4] := i OR $0B; { 3.07 enable RTS,CTS = $0B;}
inline($FB); {3.07}
Port[$20] := $20; {3.05}
term_ready(true);
END;
PROCEDURE break; {send a break}
VAR a,b: Byte;
BEGIN
a := Port[base+3];
b := (a AND $7F) OR $40;
Port[base+3] := b;
Delay(750);
Port[base+3] := a;
END;
FUNCTION exists(fname:bigstring): Boolean;
VAR f: FILE;
BEGIN
Assign(f, fname);
{$I-} Reset(f); {$I+}
IF IOResult = 0 THEN
BEGIN
exists := True;
Close(f);
END
ELSE
exists := False
END;
{This is really interesting and educational too!!!}
{NOTE: This does deserve some study!! 3.09}
PROCEDURE supcase(VAR s);
VAR ss:bigstring ABSOLUTE s; i,size:Byte;
BEGIN
{size := length(ss);} {3.09}
size := ORD(ss[0]); {3.09}
{FOR i := 1 TO size DO ss[i] := UpCase(ss[i]);} {3.09}
i := 1;
REPEAT
ss[i] := Upcase(ss[i]);
INC(i);
UNTIL i > size;
END;
PROCEDURE processcom;
VAR c,cnt: Byte;
BEGIN
IF Buffer_Count > 0 THEN {